<?php
ob_start();
session_cache_expire(999999999);
if(!isset($_SESSION)) 
{ 
session_start(); 
} 
include '../../operations/connection.php';	
$a= (string)(microtime(true)*1000);
$b=split('\.',$a);
$idcomment= $b[0];

if(!isset($_SESSION['user']))
{
	header( 'Location: login.php' );
}
else
{
	$username = $_SESSION['fullname'];
	$id_employee = $_SESSION['IDEmployee'];
}


if ($_REQUEST['newlang'] == "EN") {
			include "../../value/value_en.php";
		} else if($_REQUEST['newlang'] == "VN") {
			include "../../value/value_vn.php";
		}
		else {
			include "../../value/value_kr.php";
		}
//$datecomment = NOW();
$idtestproject = $_REQUEST['idtestpro'];
$idemploy =$_REQUEST['idemp'];
$comment =$_REQUEST['comment'];
$commentvalue= str_replace('\\r\\n','<br>',$comment."-%$#@!-#424242");

$sqladdcomment = "insert into pr_comment(IDComment,IDTestProject,IDEmployee,`Comment`,DateComment)
 VALUES('$idcomment','$idtestproject','$idemploy','$commentvalue',NOW())";
mysql_query($sqladdcomment);

$username = $_SESSION['fullname'];
$id_employee = $_SESSION['IDEmployee'];
if($username!=""){
	$sqlinserttestpro = "UPDATE pr_testproject SET Comment_Last = '$commentvalue', NameEmployee_Last = '$username'
							WHERE IDTest = '$idtestproject' ";
	mysql_query($sqlinserttestpro);
}

$querycomment = mysql_query("select c.IDComment,c.IDTestProject,c.IDEmployee,c.Comment,c.DateComment,
								 e.IDEmployee,e.FullName,c.IDTestProject from pr_comment c, employee e 
									 where c.IDEmployee = e.IDEmployee and c.IDTestProject = '$idtestproject' ORDER BY  c.DateComment ASC;")

?>


	                        <?php 
	                        if(count($querycomment)>0){
	                        	?>
	              <table style="width: 100%;">
	                        <?php  
		                        $vitri=0;
		                        while ($rowcoment = mysql_fetch_array($querycomment)){
		                        	$vitri++;
		                        		$idcomment = $rowcoment['IDComment'];
		                        		$idemployeecomment = $rowcoment['IDEmployee'];
										$stringcolor = $rowcoment['Comment'];
										if (strpos($stringcolor,"-%$#@!-#")) {
											$stringcolor =  substr($stringcolor,0,strpos($stringcolor,"-%$#@!-#"));
										}
										$stringcolor = strip_tags($stringcolor);
										?>
									
							<tr id="mo" style="background: <?php if($vitri%2==0) 
															echo '#f2f9ff'; 
													else echo '#ffffff';?>; font-size: 13px;">
								<td class="rf-dt-c" style="padding: 0; vertical-align: middle; width: auto;">
	                        
		                        	<span style=" color:#b023ab; font-size: 13px;">
		                        	<font color="#424242"><?php echo  " + ".$stringcolor ?></font>
									</span>
	                            	<i style="color:#424242; display:block; text-align:right; padding-top:5px;padding-right:15px; font-size: 13px;"><?php echo $rowcoment['FullName']." (".$rowcoment['DateComment'].")"?></i>
	                           </td>
	                           <td class="rf-dt-c" style="width: 25px; vertical-align: middle; text-align: center;min-width: 80px">
		                           <span onmouseover="this.style.cursor='pointer'" onmouseout="this.style.cursor='default'" style="color:#236DA4" 
		                           	onclick="if(confirm('<?php echo $l_confirm_deleteproject?>')){ delete_comment('<?=$idcomment?>','<?=$idtestproject?>','<?=$id_employee?>',this);return true}else{return false}">[ <?php echo $l_delete?> ]</span>
							   </td>
						</tr>
	                   <?php }?>
	               </table>
	               <?php }
	               
	               mysql_close($connection);
ob_flush();	               
	               ?>
	